import { baiduOnlineScripts, baiduOfflineScripts, esriScripts, supermapScripts, mapboxScripts } from '@/utils/mapResource'

const map = window.localStorage.getItem('MAP') || 'baidu_online'

// const map = 'baidu_offline'

const mapSource = {
    "baidu_online": baiduOnlineScripts,
    "baidu_offline": baiduOfflineScripts,
    "esri": esriScripts,
    "supermap": supermapScripts,
    "mapbox": mapboxScripts,
}

function getScripts() {
    return mapSource[map]
}
export default function (container, opts) {
    let kmap = new window.KMap(container, opts)
    kmap.setMapSource(map === 'baidu_online' || map === 'baidu_offline' ? 'baidu' : map)
    kmap.load(getScripts());
    return kmap;
}